import sys, os
sys.path.append(os.getcwd())

from selenium.webdriver.common.by import By

from base.base_action import BaseAction






class NewbiePage(BaseAction):
    # 新人壕礼页面

    # 获取新人壕礼页面”活动最终解释权归车宝金融所有“
    newboy_low_text = By.XPATH, "//li[4]"

    # 新人壕礼页面返回按钮 id = "aback"
    newreturn_button = By.XPATH, "//android.view.View[1]/android.view.View/android.view.View[1]"

    # 滑动半屏
    swipe_size = 600, 2000, 600, 650, 300

    # 新人壕礼页面”立即出借“按钮1 id="goInvest"
    start_borrow_a = By.ID, "goInvest"

    # 新人壕礼页面”立即出借“按钮2  id="goInvest1"
    start_borrow_b = By.ID, "goInvest1"

    def __init__(self, driver):
        BaseAction.__init__(self, driver)

    def swipe_half(self):
        # 滑动半屏
        return self.act_swipe(self.swipe_size)

    def click_newreturn(self):
        # 点击新人壕礼返回按钮
        self.switch_app()
        self.act_click(self.newreturn_button)

    def click_start_loan_a(self):
        # 点击新人壕礼页面立即出借a
        self.switch_web()
        self.act_click(self.start_borrow_a)

    def click_start_loan_b(self):
        # 点击新人壕礼页面立即出借b
        self.switch_web()
        self.act_click(self.start_borrow_b)

    def get_newboy_low_text(self):
        # 切换到web
        self.switch_web()
        # 获取新人壕礼底部文字
        low = self.find_element(self.newboy_low_text)
        return low.text